﻿// =================================================================== 
// 模块说明
//====================================================================
// 创建时间：2018-05-15 10:35:51
// 负责人：Sushee
// ===================================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq.Expressions;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using System.Text;
namespace OF.Component.DAL
{
	
	/// <summary>
	/// 数据访问层
	/// </summary>	
	internal partial class AuthorityMenu
	{		
    
        /// <summary>
    	/// 根据断言条件获取单个
    	/// </summary>
        public AuthorityMenuInfo QuerySingle(Expression<Func<AuthorityMenuInfo, bool>> predicate)
	    {
            return SQLServerProvider.CreateObject(ConnectionStringKey, predicate);
        }
        /// <summary>
    	/// 根据断言条件获获取列表
    	/// </summary>
	    public IList<AuthorityMenuInfo> QueryList(Expression<Func<AuthorityMenuInfo, bool>> predicate)
	    {
	        return SQLServerProvider.CreateList(ConnectionStringKey, predicate);
	    }
        ///<summary>
        ///验证MENUCODE是否存在
        ///</summary>
        public bool CheckMenuCodeIsExist(int intID)
        {
            Model.AuthorityMenuInfo info = null;
            string strSql = @"	SELECT * FROM AuthorityMenu WHERE IsActive=1 and MenuCode=@MenuCode";
            Database db = DatabaseFactory.CreateDatabase(this.ConnectionStringKey);
            DbCommand dbc = db.GetSqlStringCommand(strSql);
            db.AddInParameter(dbc, "@MenuCode", DbType.Int32, intID);
            object obj = db.ExecuteScalar(dbc);
            if (obj != null)
            {
                return (int)obj > 0;
            }
            return false;
        }
    }
	
}